package utils

import (
	"gif_project/models"
	"github.com/astaxie/beego"
)

//构造返回信息
func ResBaseJson(err error, data interface{}, controller *beego.Controller) {
	baseResponseModel := new(models.BaseResp)
	if err != nil {
		baseResponseModel.Code = 500
		baseResponseModel.Data = err.Error()
	} else {
		baseResponseModel.Code = 0
		baseResponseModel.Data = data
	}
	controller.Data["json"] = baseResponseModel
	controller.ServeJSON()
}
